#include <stdio.h>
#include <stdlib.h>
#define HOLIDAYS 20
int htable[HOLIDAYS]; /*a global holiday array*/

int main()
{
    int isHoliday(); /*function prototype*/
    int mo, day, yr, testDate;

    printf("Enter a month, day, and year: ");
    scanf("%d %d %d", &mo, &day, &yr);
    testDate = yr * 10000 + mo * 100 + day;

    if (isHoliday(testDate))
        printf("This date is a holiday.\n");
    else
        printf("This date is not a holiday.\n");

    return 0;
}

int isHoliday(int testDate)
{
    int getHolidays(); /*function prototype*/
#define TRUE 1
#define FALSE 0
    int i;

    /*read the Holiday file if the Holiday array is empty*/
    if (htable[0] == 0)
        getHolidays();

    /*search the Holiday array for the given date*/
    for (i = 0; i < HOLIDAYS; i++)
        if (testDate == htable[i])
            return TRUE;

    return FALSE;
}

int getHolidays()
{
    char HolidayFile[] = "Holidays.txt"; /*change this to the */
    int i = 0;                           /*path where the file is stored*/
    int mo, day, yr;                     /*your computer*/
    char del1, del2;
    FILE *inFile;

    inFile = fopen(HolidayFile, "r"); /*open the file*/
    /*check for a successful open*/
    if (inFile == NULL)
    {
        printf("\nFailed to open the file.\n");
        exit(1);
    }

    /*read, convert, and store each date*/
    while (fscanf(inFile, "%d%c%d%c%d", &mo, &del1, &day, &del2, &yr) != EOF)
        htable[i++] = yr * 10000 + mo * 100 + day;

    fclose(inFile);

    return i;
}